<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The ReflectionClassConstant class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionclass.tostring.html">« ReflectionClass::__toString</a></li>
      <li style="float: right;"><a href="reflectionclassconstant.construct.html">ReflectionClassConstant::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.reflection.html">反射</a></li>
    <li>The ReflectionClassConstant class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.reflectionclassconstant" class="reference">

 <h1 class="title">The ReflectionClassConstant class</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 7 &gt;= 7.1.0, PHP 8)</p>


  <div class="section" id="reflectionclassconstant.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    The <span class="classname"><strong class="classname">ReflectionClassConstant</strong></span> class reports
    information about a class constant.
   </p>
  </div>


  <div class="section" id="reflectionclassconstant.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">ReflectionClassConstant</strong>
     </span>

     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.reflector.html" class="interfacename">Reflector</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.constants.is-public"><var class="varname">IS_PUBLIC</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.constants.is-protected"><var class="varname">IS_PROTECTED</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.constants.is-private"><var class="varname">IS_PRIVATE</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.constants.is-final"><var class="varname">IS_FINAL</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.props.name">$<var class="varname">name</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.reflectionclassconstant.html#reflectionclassconstant.props.class">$<var class="varname">class</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><span class="type">object</span>|<span class="type">string</span></span> <code class="parameter">$class</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$constant</code></span>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><a href="reflectionclassconstant.export.html" class="methodname">export</a></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$class</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$return</code><span class="initializer"> = ?</span></span>): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getattributes.html" class="methodname">getAttributes</a></span>(<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$name</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span>): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getdeclaringclass.html" class="methodname">getDeclaringClass</a></span>(): <span class="type"><a href="class.reflectionclass.html" class="type ReflectionClass">ReflectionClass</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getdoccomment.html" class="methodname">getDocComment</a></span>(): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getmodifiers.html" class="methodname">getModifiers</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getname.html" class="methodname">getName</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.getvalue.html" class="methodname">getValue</a></span>(): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.isenumcase.html" class="methodname">isEnumCase</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.isfinal.html" class="methodname">isFinal</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.isprivate.html" class="methodname">isPrivate</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.isprotected.html" class="methodname">isProtected</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.ispublic.html" class="methodname">isPublic</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="reflectionclassconstant.tostring.html" class="methodname">__toString</a></span>(): <span class="type">string</span></div>

   }</div>


  </div>

  

  <div class="section" id="reflectionclassconstant.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="reflectionclassconstant.props.name"><var class="varname">name</var></dt>

     <dd>

      <p class="para">
       Name of the class constant. Read-only, throws
       <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span> in attempt to write.
      </p>
     </dd>

    
    
     <dt id="reflectionclassconstant.props.class"><var class="varname">class</var></dt>

     <dd>

      <p class="para">
       Name of the class where the class constant is defined. Read-only, throws
       <span class="classname"><a href="class.reflectionexception.html" class="classname">ReflectionException</a></span> in attempt to write.
      </p>
     </dd>

    
   </dl>

  </div>



  <div class="section" id="reflectionclassconstant.constants">
   <h2 class="title">预定义常量</h2>
   <div class="section" id="reflectionclassconstant.constants.modifiers">
    <h2 class="title">ReflectionClassConstant Modifiers</h2>
    <dl>

     
      <dt id="reflectionclassconstant.constants.is-public"><strong><code>ReflectionClassConstant::IS_PUBLIC</code></strong></dt>

      <dd>

       <p class="para">
        Indicates <a href="language.oop5.visibility.html" class="link">public</a>
        constants.
        Prior to PHP 7.4.0, the value was <code class="literal">256</code>.
       </p>
      </dd>

     

     
      <dt id="reflectionclassconstant.constants.is-protected"><strong><code>ReflectionClassConstant::IS_PROTECTED</code></strong></dt>

      <dd>

       <p class="para">
        Indicates <a href="language.oop5.visibility.html" class="link">protected</a>
        constants.
        Prior to PHP 7.4.0, the value was <code class="literal">512</code>.
       </p>
      </dd>

     

     
      <dt id="reflectionclassconstant.constants.is-private"><strong><code>ReflectionClassConstant::IS_PRIVATE</code></strong></dt>

      <dd>

       <p class="para">
        Indicates <a href="language.oop5.visibility.html" class="link">private</a>
        constants.
        Prior to PHP 7.4.0, the value was <code class="literal">1024</code>.
       </p>
      </dd>

     

     
      <dt id="reflectionclassconstant.constants.is-final"><strong><code>ReflectionClassConstant::IS_FINAL</code></strong></dt>

      <dd>

       <p class="para">
        Indicates <a href="language.oop5.final.html" class="link">final</a>
        constants. Available as of PHP 8.1.0.
       </p>
      </dd>

     

    </dl>

    <blockquote class="note"><p><strong class="note">注意</strong>: 
     <p class="para">
      The values of these constants may change between PHP versions.
      It is recommended to always use the constants
      and not rely on the values directly.
     </p>
    </p></blockquote>
   </div>
  </div>


 </div>

 






















































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="reflectionclassconstant.construct.html">ReflectionClassConstant::__construct</a> — Constructs a ReflectionClassConstant</li><li><a href="reflectionclassconstant.export.html">ReflectionClassConstant::export</a> — Export</li><li><a href="reflectionclassconstant.getattributes.html">ReflectionClassConstant::getAttributes</a> — Gets Attributes</li><li><a href="reflectionclassconstant.getdeclaringclass.html">ReflectionClassConstant::getDeclaringClass</a> — Gets declaring class</li><li><a href="reflectionclassconstant.getdoccomment.html">ReflectionClassConstant::getDocComment</a> — Gets doc comments</li><li><a href="reflectionclassconstant.getmodifiers.html">ReflectionClassConstant::getModifiers</a> — Gets the class constant modifiers</li><li><a href="reflectionclassconstant.getname.html">ReflectionClassConstant::getName</a> — Get name of the constant</li><li><a href="reflectionclassconstant.getvalue.html">ReflectionClassConstant::getValue</a> — Gets value</li><li><a href="reflectionclassconstant.isenumcase.html">ReflectionClassConstant::isEnumCase</a> — Checks if class constant is an Enum case</li><li><a href="reflectionclassconstant.isfinal.html">ReflectionClassConstant::isFinal</a> — Checks if class constant is final</li><li><a href="reflectionclassconstant.isprivate.html">ReflectionClassConstant::isPrivate</a> — Checks if class constant is private</li><li><a href="reflectionclassconstant.isprotected.html">ReflectionClassConstant::isProtected</a> — Checks if class constant is protected</li><li><a href="reflectionclassconstant.ispublic.html">ReflectionClassConstant::isPublic</a> — Checks if class constant is public</li><li><a href="reflectionclassconstant.tostring.html">ReflectionClassConstant::__toString</a> — Returns the string representation of the ReflectionClassConstant object</li></ul>
</div>
</div></div></body></html>